<?php
/**
 * ContactForm class.
 * ContactForm is the data structure for handling contact table 'tbl_merchant_contact'.
 * 
 * LBB Solutions Oy 版权所有 @ 2013
 * 
 * ----------------------------------------------------------------
 * 31.10.2013    bocheng        created this model for Contact form
 */
class ContactForm extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return ShopProfile the static model class
	 */
	public static function model($className = __CLASS__) {
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName() {
		return 'tbl_merchant_contact';
	}
	
	/**
	 * Declares the validation rules.
	 */
	public function rules()
	{
		return array(
			array('company_name, email, first_name, address, phone, city', 'required'),
			// email has to be a valid email address
			array('email', 'email', 'allowEmpty'=>false, 'checkMX'=>true),
			//array('telephone', 'match', 'pattern'=>'/^([+]?[0-9 ]+)$/', 'message'=>'The phone number is invalid!'),
			
			array('last_name, zip_code, country_code, category_key, url_site', 'safe'),
		);
	}

	/**
	 * Declares customized attribute labels.
	 * If not declared here, an attribute would have a label that is
	 * the same as its name with the first letter in upper case.
	 */
	public function attributeLabels()
	{
		return array(
			'company_name' => BUtils::T('company_name_lbl'),
			'address' => BUtils::T('street_address_lbl'),
			'email' => BUtils::T('email_address_lbl'),
			'first_name' => BUtils::T('name_first_lbl'),
			'last_name' => BUtils::T('name_last_lbl'),
			'phone' => BUtils::T('phone_number_lbl'),
			'city' => BUtils::T('city_lbl'),
			'category_key' => BUtils::T('category_lbl'),
			'url_site' => BUtils::T('web_address_lbl'),
		);
	}
}